package test2;

import java.time.LocalDate;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String s = scan.nextLine();
        int year =Integer.parseInt( s.substring(0,4));
        int moon = Integer.parseInt(s.substring(4,6));
        int day = Integer.parseInt(s.substring(6,8));
        LocalDate date = LocalDate.of(year, moon, day);
        date = date.plusDays(1);
        boolean flag = false;
        while(true){
            String newdate = date.toString().replace("-","");
            if( ishuiwen(newdate) && flag == false){
                System.out.println(newdate);
                flag = true;
            }

            if(isAB(newdate)){
                System.out.println(newdate);
                break;
            }
            date = date.plusDays(1);
        }
        scan.close();
    }

    public static boolean ishuiwen(String newdate){
        for(int i=0;i<=newdate.length()/2-1;i++){
            if( newdate.charAt(i) != newdate.charAt( newdate.length()-i-1)){
                return false;
            }
        }
        return true;
    }

    public static boolean isAB(String newdate){
        char []arr = newdate.toCharArray();
        if( arr[0] == arr[2] && arr[2] == arr[5] && arr[5]==arr[7] && arr[1]==arr[3] && arr[3] ==arr[4] && arr[4]==arr[6]){
            return true;
        }
        return false;
    }
}